 <?php echo $javascript->link('jquery.selectboxes.min.js');  ?>
 <SCRIPT type=text/javascript> 
	$(function() {
		$("#tabs").tabs().find(".ui-tabs-nav").sortable({axis:'x'});


		$('.comboChange').change(function() {
		
			var id = $(this)[0].id;
    		var values = id.split("_");		
			var selectvalue= $('#'+id +' option:selected').val();			
			var comboSelected = values[3];
			 
			$.ajax({
		        type: "post",
		        url: "<?php echo $this->base?>/admin/ktcontrollers/getListRows/"+selectvalue,
		        data: selectvalue,
		        dataType: 'json',
		        success: function(response){ 
				$("#combo_row_id_"+comboSelected).removeOption(/./);
				$("#combo_row_name_"+comboSelected).removeOption(/./);
				    $.each(response, function(i,item){	 
					    
					    var option = item;
						 $("#combo_row_id_"+comboSelected).addOption(option,option);
						 $("#combo_row_name_"+comboSelected).addOption(option,option);
						 
				    });
		        }
	        
		        });   		 
    		 	    
		});

		$('.selectAll').click(function(){	
			var value = $(this)[0].id;	
			if (value == "checkAll") {
					 $('.check_class').each(function(i) {
					    	// activamos				    		
					    	$(this).attr("checked","checked");				    	
					    	
					 })
			} else if (value == "checkAdminAll") {
				 $('.check_admin_class').each(function(i) {
				    	// activamos 
				    	$(this).attr("checked","checked");
				 })	
			}	 
		
		});
		

		
	});
	</SCRIPT>


<div class="kt-g1">
		<div class=" kt-right">
	   		<ul class="lst-tabs">
	   		   		<li id="icon-controllers" class="active"><a href="<?php echo $this->base.'/admin/ktcontrollers' ?>"><span class="icon"></span><?php __('controladores'); ?></a></li>	
	  		</ul>	  
		</div>
</div>
<div class="kt-md-content">	 
 <?php if (isset($configuration)){ ?>
<div class="kt-md-configuracion"> 	
	 	
	 	<div class="bd lst-form">
		 	  <table>
		 	  <tr>
			 	  <td> <p>  <strong> <?php __('configuration_name') ?> </strong></p>
			 	       <p> <?php echo $configuration["name"] ?></p>
			 	  </td>     
			 	  <td> 
			 	    <p> <strong><?php __('configuration_directory') ?> </strong></p>
			 	    <p> <?php echo $configuration["directory"] ?></p>
			 	  </td>	 	  
		 	  </tr>	 	  
		 	  </table> 
		</div>
		
</div>
 <?php } ?>
 <?php if (!is_writable(CONTROLLERS)) { ?>					
		  		<div class="kt-md  configuration_error">
		  		<div class="bd">
						<p class="error_msg"> <?php  __('Your directory  is NOT writable.'); ?> 
				  				<?php  __('generation  will not work correctly'); ?>
				 		</p> 
				 </div>
			 	</div>
<?php	} ?>
<?php echo $form->create("Ktcontroller", array('action' => 'admin_norender')); ?>
<div class="kt-md">
		<div class="hd">
			<p id="icon-tools" class="icon32"></p>
			<h2> <?php __('controllers_title_generate') ?>  - <?php echo $name ?></h2>
			
		</div>
	
<div class="bd">	
	<div id="tabs">
	   <ul>
	      <li><a href="#tabs-1"> <?php echo __('methods') ?></a></li>
	      <li><a href="#tabs-2"> <?php echo __('helpers');  ?>, <?php echo __('components') ?></a></li>	    
	      <li><a href="#tabs-3"> <?php echo __('selector/s') ?></a></li>
	      <li><a href="#tabs-4"> <?php echo __('paginator') ?></a></li>
	   </ul>
	
	<div id="tabs-1"> 
		<div class="kt-g2a">
			<div class="kt-gu first-g">
				<div class="kt-md">
						<div class="hd">
							<h3><?php echo __('methods') ?></h3>
							<h5><?php echo __('methods_legend') ?></h5>
						</div>			
						<div class="bd lst-form">
							<div class="kt-md-group">		
							<table> 
								<tr class="form-field">
									<td>					
										<p>
											<?php echo $form->label('usercheck][index]',__('function_index',true),array('class'=> 'label_check')); ?>
											<?php echo $form->checkbox('usercheck][index]',array('class'=> 'check_class')); ?>
										</p> 					
									</td>
									<td>
										<p>
											<?php echo $form->label('usercheck][add',__('function_add',true),array('class'=> 'label_check')); ?>
											<?php echo $form->checkbox('usercheck][add',array('class'=> 'check_class')); ?>
										</p> 						
									</td>
								</tr>				
								<tr class="form-field">
									<td>
										<p>
											<?php echo $form->label('usercheck][view',__('function_view',true),array('class'=> 'label_check')); ?>
											<?php echo $form->checkbox('usercheck][view',array('class'=> 'check_class')); ?>
										</p> 				
									</td>
									<td>
										 <p>
											 <?php echo $form->label('usercheck][edit',__('function_edit',true),array('class'=> 'label_check')); ?>
											<?php echo $form->checkbox('usercheck][edit',array('class'=> 'check_class')); ?>
										</p> 			 				
									</td>
								</tr>
								<tr class="form-field">
									<td>
										<p>
											<?php echo $form->label('usercheck][del',__('function_delete',true),array('class'=> 'label_check')); ?>
											<?php echo $form->checkbox('usercheck][del',array('class'=> 'check_class')); ?>
										</p> 				
									</td>
									<td>
										 		 				
									</td>
								</tr>
							</table>	
							</div>
							<div class="kt-md-group">		
								<table>
								<tr class="form-field">
									<td>					
										<p>
											<label for="checkAll"><? echo __('Seleccionar todos'); ?></label>
											<input  type="checkbox" id="checkAll" class="selectAll" />
										</p> 					
									</td>
								</tr>	
								</table>			 
						    </div>	
						  </div>	
					</div>
			</div>
			<div class="kt-gu">
				<div class="kt-md">
			<div class="hd">
				<h3> <?php echo __('admin_methods') ?></h3>
				<h5> <?php echo __('admin_methods_legend') ?></h5>
			</div>			
			<div class="bd lst-form">
				<div class="kt-md-group">				
				<table>
					<tr class="form-field">
						<td>					
							<p>
								<?php echo $form->label('admincheck][index]',__('function_index',true),array('class'=> 'label_check')); ?>
								<?php echo $form->checkbox('admincheck][index]',array('class'=> 'check_admin_class')); ?>
							</p> 					
						</td>
						<td>
							<p>
								<?php echo $form->label('admincheck][add',__('function_add',true),array('class'=> 'label_check')); ?>
								<?php echo $form->checkbox('admincheck][add',array('class'=> 'check_admin_class')); ?>
							</p> 						
						</td>
					</tr>				
					<tr class="form-field">
						<td>
							<p>							
								<?php echo $form->label('admincheck][view',__('function_view',true),array('class'=> 'label_check')); ?>
								<?php echo $form->checkbox('admincheck][view',array('class'=> 'check_admin_class')); ?>
							</p> 				
						</td>
						<td>
						    <p>
								<?php echo $form->label('admincheck][edit',__('function_edit',true),array('class'=> 'label_check')); ?>
								<?php echo $form->checkbox('admincheck][edit',array('class'=> 'check_admin_class')); ?>
							</p> 			 				
						</td>
					</tr>
					<tr class="form-field">
						<td>
							<p>
								<?php echo $form->label('admincheck][del',__('function_delete',true),array('class'=> 'label_check')); ?>
								<?php echo $form->checkbox('admincheck][del',array('class'=> 'check_admin_class')); ?>
							</p> 				
						</td>
						<td>	 				
						</td>
					</tr>
				</table>
				 </div>
				 <div class="kt-md-group">		
				 <table>
				<tr class="form-field">
					<td>					
						<p>
							<label for="checkAdminAll"><? echo __('Seleccionar todos'); ?></label>
							<input  type="checkbox" id="checkAdminAll" class="selectAll" />
						</p> 					
					</td>
				</tr>
				</table>
				</div>
			</div>	
		</div>
			</div>
		</div>
	
	
	</div>	
	

	
	<div id="tabs-2"> 
			<div class="kt-g2a">
				<div class="kt-gu first-g">
					<div class="kt-md">
						<div class="hd">
							<h3> <?php echo __('helpers') ?></h3>
							<h5> <?php echo __('helpers_legend') ?></h5>
						</div>			
						<div class="bd lst-form kt-md-group">
								<table>
						 			 <tr class="form-field">
						 				 <td>
						 				 	<?php echo $form->input("helpers][info]", array('label' => __('select_helpers',true))); ?>
						 				  	<p class="otherinfo"></p>
						 				 </td>
						 			 </tr>
						 		</table>			 	
							</div>						
						</div>		
					</div>
				
				<div class="kt-gu">
					<div class="kt-md">
						<div class="hd">
							<h3><?php echo __('components') ?></h3>
							<h5><?php echo __('components_legend') ?></h5>
						</div>			
						<div class="bd">			
							<div class="lst-form kt-md-group">				
								<table>
						 			 <tr class="form-field">
						 				 <td>
						 				 <?php echo $form->input("components][info]", array('label' => __('select_components',true))); ?>
						 				 <p class="otherinfo"></p>
						 				 </td>
						 			 </tr>			 			 
						 		</table>			 	
							</div>						
						</div>		
					</div>
				</div>
			</div>	
	</div>
	 
	<div id="tabs-3"> 
		<div class="kt-md">
			<div class="hd">
				<h3><?php echo __('Relations by select with other tables') ?></h3>
				<h5><?php echo __('If you want make automatic a select from other table, you only have to configure fields and in GENERATE VIEW, select fields like select. You can configure until 3 combo relations from other models') ?></h5>
				
			</div>			
			<div class="bd">	
				<div class="lst-form kt-md-group">
					<p><?php echo __('First configuration') ?></p>			
					<table>
			 			<tr class="form-field">
							<td>
							    <?php echo $form->input("selector][1][model]", array("type" => "select", "label"=>__('Configuration select model',true), "class"=>"comboChange", "id" =>"combo_row_table_1" ,"options"=>$selectTables, "empty"=>true)); ?>
							</td>
							<td>	
								<?php echo $form->input("selector][1][label]", array("type" => "select", "label"=>__('field name other table',true), "id" =>"combo_row_name_1" ,"options"=>"", "empty"=>false)); ?>
			
							</td>
							<td>	
								<?php echo $form->input("selector][1][value]", array("type" => "select", "label"=>__('id name other table',true), "id" =>"combo_row_id_1", "options"=>"", "empty"=>false)); ?>
							</td>				
						</tr> 
					</table>
					<p><?php echo __('Second configuration') ?></p>		
					<table>	
						<tr class="form-field">
							<td>
							    <?php echo $form->input("selector][2][model]", array("type" => "select", "label"=>__('Configuration select model',true), "class"=>"comboChange", "id" =>"combo_row_table_2" ,"options"=>$selectTables, "empty"=>true)); ?>
							</td>
							<td>	
								<?php echo $form->input("selector][2][label]", array("type" => "select", "label"=>__('field name other table',true), "id" =>"combo_row_name_2" ,"options"=>"", "empty"=>false)); ?>
			
							</td>
							<td>	
								<?php echo $form->input("selector][2][value]", array("type" => "select", "label"=>__('id name other table',true), "id" =>"combo_row_id_2", "options"=>"", "empty"=>false)); ?>
							</td>				
						</tr> 
					</table>
					<p><?php echo __('Third configuration') ?></p>		
					<table>
						<tr class="form-field">
							<td>
							    <?php echo $form->input("selector][3][model]", array("type" => "select", "label"=>__('Configuration select model',true), "class"=>"comboChange", "id" =>"combo_row_table_3" ,"options"=>$selectTables, "empty"=>true)); ?>
							</td>
							<td>	
								<?php echo $form->input("selector][3][label]", array("type" => "select", "label"=>__('field name other table',true), "id" =>"combo_row_name_3" ,"options"=>"", "empty"=>false)); ?>
			
							</td>
							<td>	
								<?php echo $form->input("selector][3][value]", array("type" => "select", "label"=>__('id name other table',true), "id" =>"combo_row_id_3", "options"=>"", "empty"=>false)); ?>
							</td>				
						</tr> 
			 		</table>			 	
				</div>						
			</div>	
			<div class="ft">
			<p><strong>Field name</strong> is the text or label for de select</p>
			<p><strong>Field id</strong> is the value for de select</p>
			</div>	
		</div>
	</div>	
	<div id="tabs-4"> 
		<div class="kt-md">
			<div class="hd">
				<h3><?php echo __('Paginator') ?></h3>			
			</div>			
			<div class="bd">			
				<div class="lst-form kt-md-group">				
					<table>
			 			 <tr class="form-field">
			 			     <td>
			 				 <?php echo $form->input("paginator][nelements]", array('label' => __('Number elements 5,10,15',true))); ?>
			 		 		 </td>
			 				 <td colspan="2">
			 				 <?php echo $form->input("paginator][order]", array('label' => __('Order By, add fields',true))); ?>
			 		 		 </td>
			 			 </tr>			 			 
			 		</table>			 	
				</div>						
			</div>		
		</div>
	</div>	
	 
	 
	 
	</div> <!-- fin tabs -->	
	
	<?php echo $form->input('names', array('type' => 'hidden','value' => $name));?> 
	<?php echo $form->input('userDbConfig', array('type' => 'hidden','value' => $userDbConfig));?> 
	<p class="submit"><?php echo $form->submit(__('generate',true)); ?></p>		
	<?php echo $form->end();?>
</div>	
</div>	
</div>